/**
* Copyright (c) By zengqh.
*
* This program is just for fun or demo, in the hope that it  
* will be useful, you can redistribute it and/or modify freely.
*
* Time: 2013/03/16
* File: MeshLoader.h
* Blog: http://www.cnblogs.com/zengqh/
**/

#pragma once

namespace HY
{
class MeshLoader
{
public:
	bool load(Mesh& mesh, File& file);
	bool loadParams(Mesh& mesh, File& file, bool static);
	bool save(Mesh& mesh, File& file);

public:
	MeshLoader();
	virtual ~MeshLoader();

protected:
	bool readMeshFile(Mesh& mesh, File& file, MeshFile::Chunk &chunk, bool is_static) const;
	bool readMaterials(Mesh& mesh, File& file) const;

	bool readMesh(Mesh& mesh, File& file, bool is_static) const;
	bool readLODLevel(File& file, MeshLODLevel& lod_level, bool is_static) const;
	bool readIndexBuffer(File& file, IndexBuffer& idx_buf, bool is_static) const;

	bool readGeometry(File& file, Geometry& geo) const;

	bool readMorphTarget(File& file, Mesh& mesh, bool is_static) const;
	bool readVertexBuffer(File& file, VertexBuffer& vb, uint32 idx, bool is_static) const;
	bool readVertexAttribute(File& file, VertexBuffer& vb) const;

	bool readMeshBoundingBox(Mesh& mesh, File& file) const;

	MeshFile::Chunk readChunk(File& file) const;
};
}